﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

using ColladaDotNet;

using Microsoft.Xml.Serialization.GeneratedAssembly;

namespace CopyDae2Dae
{
	class Program
	{
		private static bool overwright;

		private static COLLADA dstFile;

		static void Main(string[] args)
		{
#if DEBUG
			if (args.Length == 0)
			{
				args =
						@"-s src\man_pistol.DAE -d src\torso.DAE -o mix\man_torso_pistol.DAE library_animations library_cameras #node-Dummy01 #node-Bip01 #node-Pistol"
								.Split(
								new char[] { ' ' });
			}
#else
#endif
			string srcFileName = null;
			string dstFileName = null;
			string outputFileName = null;
			overwright = false;
			for (int i = 0; i < args.Length; i++)
			{
				var arg = args[i];
				if (arg[0] == '-' || arg[0] == '/')
				{
					switch (arg.Substring(1).ToLower())
					{
						case "s":
						case "source":
						case "i":
						case "input":
							srcFileName = args[i + 1];
							++i;
							break;
						case "d":
						case "destination":
							dstFileName = args[i + 1];
							++i;
							break;
						case "o":
						case "output":
							outputFileName = args[i + 1];
							++i;
							break;
						case "overwright":
							overwright = true;
							++i;
							break;
					}
				}
				
			}

			COLLADA.Serializer = new COLLADASerializer();

			COLLADA src = COLLADA.Load(srcFileName);
			dstFile = COLLADA.Load(dstFileName);

			src.CopyTo(dstFile, overwright);


			

			dstFile.Save(outputFileName);
		}

		

		
	}
}
